package com;

// 构造方法
class MyClass {
    int x;

    // 构造函数
    MyClass() {
        x = 10;

    }
}

public class method {

    public static int Add(int a, int b) {
        return a + b;
    }

    public static double Add(double a, double b) {
        return a + b;
    }

    public static void printGrade(double score){
        if (score > 90.0){
            System.out.println('A');
        }
        else if (score >= 80.0){
            System.out.println('B');
        }
        else if (score >= 70.0){
            System.out.println('C');
        }
        else if (score >= 60.0){
            System.out.println('D');
        }
        else {
            System.out.println('E');
        }
    }

    public static int max(int num1, int num2) {
        return num1 > num2 ? num1 : num2;
    }

    public static void swap(int n1, int n2){
        System.out.println("交换前: " + "n1 = " + n1 + "  n2 = " + n2);
        int temp = n1;
        n1 = n2;
        n2 = temp;
        System.out.println("交换后: " + "n1 = " + n1 + "  n2 = " + n2);
    }

    public static void main(String[] args) {
        int k = Add(1, 5);
        System.out.println("k = " + k);

        double j = Add(128942.3, 58050.564);
        System.out.println("j = " + j);

        int a = 34;
        int b = 53;
        int m = max(a,b);
        System.out.println("The max num is = " + m);
        System.out.printf("Ths max num is %s \n",m);

        printGrade(98.5);

        swap(154,53);
        // 创建 MyClass 的实例以调用构造函数
        MyClass myClassInstance = new MyClass(); // 实例化
        System.out.println("x = " + myClassInstance.x);
    }
}
